﻿@model SimpleIdServer.IdServer.UI.ViewModels.AuthenticatePasswordViewModel
@using SimpleIdServer.IdServer.ConformanceSuite.Startup.Resources

@{
    ViewBag.Title = AuthenticatePasswordResource.title;
}

@if (!ViewData.ModelState.IsValid)
{
    <ul class="list-group">
        @foreach (var modelState in ViewData.ModelState.Values)
        {
            foreach (var error in modelState.Errors)
            {
                <li class="list-group-item list-group-item-danger">@AuthenticatePasswordResource.ResourceManager.GetString(error.ErrorMessage)</li>
            }
        }
    </ul>
}

@using (Html.BeginForm("Index", "Authenticate", new { area = "pwd", returnUrl = Model.ReturnUrl }, FormMethod.Post))
{
    @Html.AntiForgeryToken()
    <input type="hidden" value="@Model.ReturnUrl" name="ReturnUrl" />
    <!-- Login -->
    <div class="input-group mb-3">
        <input type="text" value="@Model.Login" name="Login" class="form-control" placeholder="@AuthenticatePasswordResource.login">
    </div>
    <!-- Password -->
    <div class="input-group mb-3">
        <input type="password" value="@Model.Password" name="Password" class="form-control" placeholder="@AuthenticatePasswordResource.password">
    </div>
    <div>
        <input type="checkbox" value="@Model.RememberLogin" name="RememberLogin" />
        <label>@AuthenticatePasswordResource.remember_login</label>
    </div>
    <button type="submit" class="btn btn-primary">@AuthenticatePasswordResource.submit</button>
}

@section SubScripts {
    <script type="text/javascript">
        $(document).ready(function () {
            $(".login input[name='RememberLogin']").change(function (e) {
                $(this).val($(this).is(':checked'));
            });
        });
    </script>
}